<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/vuex/dist/vuex.js"></script>
</head>
<body>
<div id="app"></div>

<script>
    //创建一个 store
    const store = new Vuex.Store({
        //state存储应用层的状态
        state: {
            count: 5  //总数：5
        },
        getters:{
            newCount: state => state.count * 3
        },
        //更改store状态的唯一途径
        mutations: {
            increment (state,n) {
                state.count +=n;
            }
        }
    });

    const app = new Vue({
        el: "#app",
        store
    });
</script>

</body>
</html>